package com.lehecai.core.game;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * 游戏类型
 * @author He Wang
 */
public class GameType extends IntegerBeanLabelItem {

    private static final long serialVersionUID = 7009455804239792650L;
    private static final Logger logger = LoggerFactory.getLogger(GameType.class.getName());

    private static List<GameType> items = new ArrayList<GameType>();
    private static List<GameType> queryItems = new ArrayList<GameType>();

    protected GameType(String name, int value) {
        this(name, value, false);
    }

    protected GameType(String name, int value, boolean queryOnly) {
        super(GameType.class.getName(), name, value);
        queryItems.add(this);
        if (!queryOnly) {
            items.add(this);
        }
    }

    public static GameType getItem(int value){
        try {
            return (GameType)GameType.getResult(GameType.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    public static List<GameType> getItems() {
        return items;
    }

    public static List<GameType> getQueryItems() {
        return queryItems;
    }

    public static final GameType ALL = new GameType("全部", -1, true);
    public static final GameType LOTTERY_GAME = new GameType("彩票游戏", 1);
    public static final GameType LHC_GAME = new GameType("乐和彩游戏", 2);
    public static final GameType THIRD_PARTY_INITIATIVE_GAME = new GameType("三方游戏主动接入", 3);
    public static final GameType THIRD_PARTY_PLATFORM_GAME = new GameType("三方游戏平台接入", 4);
}
